import { ReturnResult } from '@/types/http';
import {
  httpDelete,
  httpGet,
  httpPost,
  httpPut,
} from '@/utils/http';

export function getAllFieldsCities(): Promise<ReturnResult> {
  return httpGet({
    url: '/yixiantong-cities/all-cities',
    params: {},
  });
}

export function getFieldsCityList(
  page: number,
  pageSize: number,
  keyword: string
) {
  return httpGet<ReturnResult>({
    url: '/yixiantong-cities/list',
    params: {
      page,
      pageSize,
      keyword,
    },
  });
}

export function getFieldsCityDetail(id: number | string) {
  return httpGet<ReturnResult>({
    url: `/yixiantong-cities/${id}`,
    params: {
      id,
    },
  });
}

export function createFieldsCity<T extends object>(data: T) {
  return httpPost<ReturnResult>({
    url: '/yixiantong-cities/',
    params: data,
  });
}

export function updateFieldsCity<T extends object>(id: number | string, data: T) {
  return httpPut<ReturnResult>({
    url: `/yixiantong-cities/${id}`,
    params: data,
  });
}

export function removeFieldsCity(id: number | string) {
  return httpDelete<ReturnResult>({
    url: `/yixiantong-cities/${id}`,
    params: {},
  });
}
